<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
    function createAction(submitAction) {
        afterSubmitRedirect("lookup", "create.html", submitAction, "submitAction");
    }

    function editAction(submitAction) {
        afterSubmitRedirect("lookup", "edit.html", submitAction, "submitAction");
    }
</script>

<body>
    <!--START: Wrapper -->
    <div id="wrapper">
        <!--START: Header -->
        <div class="header">
            <h1>
                <a href="#">logo</a>
            </h1>
        </div>
        <!--END: Header -->
        <!--START: conent -->
        <div class="content">
		        <div class="menu">
		            <ul>
		                <li><a href="#">Questionnaires</a></li>
		                <li><a href="<%= request.getContextPath()%>/designer/questionset/list.html">Question Sets</a></li>
		                <li><a href="<%= request.getContextPath()%>/designer/question/list.html">Questions</a></li>
		                <li class="active"><a href="<%= request.getContextPath()%>/designer/lookup/index.html">Lookup Tables</a></li>
		                <li><a href="<%= request.getContextPath()%>/designer/user/list.html">Users</a></li>
		                <li><a href="<%= request.getContextPath()%>/designer/group/list.html">Groups</a></li>
		            </ul>
		        </div>
            <div class="breadcrumb">
                <div class="links">
                    <a href="/dialogs">Admin</a> &gt;
                    <a href="<%=request.getContextPath()%>/designer/lookup/listlookup.html">Lookup Tables</a> &gt;
                    <a href="listdatavalidation.html">DataValidations</a> &gt;(Add, Edit)
                </div>
                <ul class="functions">
                    <li class="active">
                        <a href="#">General</a>
                    </li>
                </ul>
            </div>
            <div class="insider">
                <div class="column1">
                    <dl class="formlayout">
                        <form id="lookup" method="post">

                            <input type="hidden" id="submitAction" name="submitAction" />
                            <input type="hidden" name="lookupType" value="${lookupType}" />

                            <dd>
                                <label for="User ID">
                                    DataValidation Code:
                                </label>
                                <c:if test="${IS_CREATE}">
                                    <input name="code" type="text" value="${lookup.code}" class="input1" />
                                    <font color="red">${errors['code.errors'][0]}</font>
                                </c:if>
                                <c:if test="${IS_EDIT}">
                                    ${lookup.code}
                                </c:if>
                            </dd>

                            <dd>
                                <label for="Name">
                                    Name:
                                </label>
                                <input name="name" type="text" value="${lookup.name}" class="input1" />
                                <font color="red">${errors['name.errors'][0]}</font>
                            </dd>
                            
                            <dd>
                                <label for="Expression">
                                    Expression:
                                </label>
                                <input name="expression" type="text" value="${lookup.expression}" class="input1" />
                                <font color="red">${errors['expression.errors'][0]}</font>
                            </dd>

                            <dd>
                                <label for="First Name">
                                    Description:
                                </label>
                                <input name="description" type="text" value="${lookup.description}" class="input1" />
                                <font color="red">${errors['description.errors'][0]}</font>
                            </dd>

                            <dd class="spacing1">
                                <label for="DataValidationType">
                                    DataValidationType:
                                </label>
                                <select name="dataValidationType.code" class="select1">
                                    <c:forEach var="dvt" items="${dvts}">
                                        <option ${dvt.code eq lookup.dataValidationType.code ? 'selected' : ''} value="${dvt.code}">
                                            ${dvt.code}
                                        </option>
                                    </c:forEach>
                                </select>
                            </dd>
                            
                            <dd class="spacing1">
                                <label for="Group">
                                    Group:
                                </label>
                                <select name="userGroup.name" class="select1">
                                    <c:forEach var="userGroup" items="${groups}">
                                        <option ${userGroup.name eq lookup.userGroup.name ? 'selected' : ''} value="${userGroup.name}">
                                            ${userGroup.name}
                                        </option>
                                    </c:forEach>
                                </select>
                            </dd>
                        </form>
                        <dd>
                            <label for="Last Modified Date">
                                Last Modified Date:
                            </label>
                            ${lookup.modifiedOn}
                        </dd>
                        <dd>
                            <label for="Last Modified By">
                                Last Modified By:
                            </label>
                            ${lookup.modifiedBy}
                        </dd>
                    </dl>
                    <font color="red">
                        <c:out value="${message}"></c:out>
                        <br />
                    </font>
                </div>
                <ul class="functions1">
                    <li>
                        <c:if test="${IS_CREATE}">
                            <a href="#" onclick="createAction('submit');"> Save </a>
                        </c:if>
                        <c:if test="${IS_EDIT}">
                            <a href="#" onclick="editAction('submit')">Save</a>
                        </c:if>
                    </li>
                    <li>
                        <c:if test="${IS_CREATE}">
                            <a href="#" onclick="createAction('submit_and_exit');"> Save &amp;
                            Exit</a>
                        </c:if>
                        <c:if test="${IS_EDIT}">
                            <a href="#" onclick="editAction('submit_and_exit')">Save &amp;
                            Exit</a>
                        </c:if>

                    </li>
                    <li>
                        <c:if test="${IS_CREATE}">
                            <a href="#" onclick="createAction('submit_and_new');">Save &amp; Create New</a>
                        </c:if>
                        <c:if test="${IS_EDIT}">
                            <a href="#" onclick="editAction('submit_and_new')">Save &amp; Create New</a>
                        </c:if>
                    </li>
                    <li>
                        <a href="cancel.html?lookupType=${lookupType}"> Cancel</a>
                    </li>
                </ul>
            </div>
        </div>

        <!--END: conent -->
        <!--START: Footer -->
        <div class="footer"></div>
        <!--END: Footer -->
    </div>
    <!--END: Wrapper -->
</body>